csd: Improve window button handling
authorMatthias Clasen <mclasen@redhat.com>
Sat, 29 Jun 2013 22:18:35 +0000 (18:18 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 29 Jun 2013 23:00:40 +0000 (19:00 -0400)
Group the buttons on each side in a box, and give them different
style classes, so themes can differentiate (this is partially a
workaround for limitations in our css selectors). The boxes also
let us add a margin below the buttons, without affecting the
allocation of the buttons themselves.

gtk/gtkwindow.c

index b7cb9da67276bce53bce79e1eafd5451ae067858..eb2a12f0c8fbea7bcc60da7f8459ba257cabd35c 100644 (file)
@@ -5046,11 +5046,13 @@ update_window_buttons (GtkWindow *window)
 {
   GtkWindowPrivate *priv = window->priv;
   gboolean maximized;
+  GtkTextDirection direction;
 
   if (priv->title_box == NULL)
     return;
 
   maximized = gtk_window_get_maximized (window);
+  direction = gtk_widget_get_direction (GTK_WIDGET (window));
 
   if (priv->fullscreen ||
       (maximized && priv->hide_titlebar_when_maximized))
@@ -5107,9 +5109,24 @@ update_window_buttons (GtkWindow *window)
         {
           for (i = 0; i < 2; i++)
             {
+              GtkWidget *box;
+
               if (tokens[i] == NULL)
                 continue;
 
+              box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+              gtk_widget_show (box);
+              gtk_widget_set_margin_bottom (box, 6);
+              if ((direction == GTK_TEXT_DIR_LTR && i == 0) ||
+                   (direction == GTK_TEXT_DIR_RTL && i == 1))
+                gtk_style_context_add_class (gtk_widget_get_style_context (box), "left");
+              else
+                gtk_style_context_add_class (gtk_widget_get_style_context (box), "right");
+              if (i == 0)
+                gtk_header_bar_pack_start (GTK_HEADER_BAR (priv->title_box), box);
+              else
+                gtk_header_bar_pack_end (GTK_HEADER_BAR (priv->title_box), box);
+
               t = g_strsplit (tokens[i], ",", -1);
               for (j = 0; t[j]; j++)
                 {
@@ -5181,12 +5198,7 @@ update_window_buttons (GtkWindow *window)
                     }
 
                   if (button)
-                    {
-                      if (i == 0)
-                        gtk_header_bar_pack_start (GTK_HEADER_BAR (priv->title_box), button);
-                      else
-                        gtk_header_bar_pack_end (GTK_HEADER_BAR (priv->title_box), button);
-                    }
+                    gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
                 }
               g_strfreev (t);
             }